#!/bin/sh

#Installation script
#$1: DESTDIR; $2: BUILDDIR

if [ ! "$#" -eq 2 ]; then
    echo "Internal use only."
    exit 1
fi

DESTDIR="$1"
BUILDDIR="$2"
INSTALL_USER=$(whoami)

. ./common.sh

stateSet "Creating directories..."
install -d "$DESTDIR/lib/pkgconfig" "$DESTDIR/include/icecode/test"
checkCommand $?

stateSet "Copying library..."
install "$BUILDDIR/libicecode-test.a" "$DESTDIR/lib"
checkCommand $?

stateSet "Copying include files..."
install src/*.hpp "$DESTDIR/include/icecode/test"
checkCommand $?

stateSet "Copying library metadata..."
install "$BUILDDIR/icecode-test.pc" "$DESTDIR/lib/pkgconfig"
checkCommand $?

if [ "$INSTALL_USER" = "root" ] ; then
    stateSet "Updating the library cache..."
    ldconfig
    checkCommand $?
fi
